• File: db_connect.php
  • Full Path: C:/htdocs/reeft_gps_test/css/include/db_connect.php
  • Date Modified: 04/30/2025 7:56 AM
  • File size: 2.75 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php
//======================================================================================
//
// Function: Connect to a database
//
// NOTE: config.php must have been include before you include this!
//
// Programmer: JKJ
// Date      : 2022-01-06
//
// ------------------------------------------------------------------------------------------
// One year since the crazy fvcking Trump supporters tried to overcome US democracy.
// FVCK TRUMP AND ALL HIS SUPPORTERS AND DF AND NY BOGERLIGE AND ALL RIGHT WING SHITHEADS!!!!
// ------------------------------------------------------------------------------------------
//
// Copyright Reeft A/S (c) - 2021
//======================================================================================

	if ( $DFT_DATABASE_TO_USE == '*MYSQL') {

		//include "include/web-connect-mysql.php";
		
		$hostname = 'localhost';
		$username = 'admin';
		$password = 'costello';
		$database = 'reeft_db';

		try {
			$file_db = new PDO("mysql:host=$hostname;dbname=$database;charset=utf8mb4", $username, $password);
			// Set the PDO error mode to exception
			$file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
			//$file_db->set_charset('utf8mb4');
			//echo "Connected successfully"; 
		} catch (PDOException $e) {
			echo "Connection failed: " . $e->getMessage();
		}		

	}
	else if ( $DFT_DATABASE_TO_USE == '*MARIA_DB') {

		
		$hostname 	= '127.0.0.1';
		$username 	= 'admin';
		$password 	= 'costello';
		$database 	= 'reeft_db';
		$port 		= '3307';

		try {
			$file_db = new PDO("mysql:host=$hostname;dbname=$database;port=$port;charset=utf8mb4", $username, $password);
			// Set the PDO error mode to exception
			$file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
			//$file_db->set_charset('utf8mb4');
			//echo "Connected successfully"; 
		} catch (PDOException $e) {
			echo "Connection failed: " . $e->getMessage();
		}		

	}
	else if ( $DFT_DATABASE_TO_USE == '*PGSQL') {

		
		$hostname = 'localhost';
		$username = 'postgres';
		$password = 'costello';
		$database = 'reeft_db';

		try {
			$file_db = new PDO("pgsql:host=$hostname;dbname=$database;user=$username;password=$password");			
			// Set the PDO error mode to exception
			$file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
			//$file_db->set_charset('utf8mb4');
			//echo "Connected successfully"; 
		} catch (PDOException $e) {
			echo "Connection failed: " . $e->getMessage();
		}		

	}
	else
	{

		$DFT_SQLLITE_IP = $DFT_SQLLITE_IP;

		// Conncetion is found in /config/config.php
		$file_db = new PDO("sqlite:$DFT_SQLLITE_IP");

		// Set errormode to exceptions
		$file_db->setAttribute(PDO::ATTR_ERRMODE,
							   PDO::ERRMODE_EXCEPTION);


	}


?>